package com.semp.jadoma.admin.utils.media;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import com.semp.jadoma.admin.utils.Config;

public class FileSaver {

	public final static File save(InputStream inputStream, String fileId) throws IOException {
		File outputFile = new File(Config.IMAGE_FULL_PATH + File.separator + fileId + "." + System.currentTimeMillis() + ".jpg");
		FileOutputStream fos = new FileOutputStream(outputFile);
		byte[] buf = new byte[1024];
		int i = 0;
		while ((i = inputStream.read(buf)) != -1) {
			fos.write(buf, 0, i);
		}
		inputStream.close();
		fos.close();
		
		return outputFile;
	}

}
